import "package:flutter/material.dart";
import "package:myapp/_common/NestedTabBarView.dart";
import "widget/live/LiveListTabWidget.dart";
import "widget/live/LiveRecommendListWidget.dart";
import "widget/live/LiveSubscribeWidget.dart";
import "widget/live/LiveSwiperWidget.dart";

// 首页-直播
class LiveWidget extends StatefulWidget {
  const LiveWidget({super.key});

  @override
  State<StatefulWidget> createState() {
    return _LiveWidgetState();
  }
}

class _LiveWidgetState extends State<LiveWidget> {
  final List<String> tabList = ['推荐', '人气', '颜值', '英雄联盟', '虚拟主播', '王者荣耀', '娱乐'];
  int tabActive = 0;
  @override
  Widget build(BuildContext context) {
    return CustomScrollView(
      controller: NestedInnerScrollController.maybeOf(context),
      slivers: [
        // 处理嵌套遮挡问题
        SliverOverlapInjector(
          handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
        ),
        const LiveSwiperWidget(),
        LiveSubscribeWidget(),
        LiveListTabWidget(
          tabList: tabList,
          initActive: tabActive,
          onChange: (int val) {
            tabActive = val;
          },
        ),
        tabActive == 0
            ? LiveRecommendListWidget()
            : const SliverToBoxAdapter(
                child: SizedBox.shrink(),
              ),
        const SliverToBoxAdapter(
          child: SizedBox(
            height: 100,
          ),
        )
      ],
    );
  }
}
